package group.sicher.common.constant.senum;

import lombok.Getter;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;

/**
 * 活动分类 0:满减 1:其他'
 */
@Getter
public enum ActivityTypeEnum {
    FULL_REDUCTION_ACTIVITY(0, "满减"),
    OTHER_ACTIVITY(1, "其他");

    private int code;
    private String desc;

    private static final Map<Integer, ActivityTypeEnum> lookupInt = new HashMap<>();
    private static final Map<String, ActivityTypeEnum> lookupString = new HashMap<>();

    static {
        for (ActivityTypeEnum type : EnumSet.allOf(ActivityTypeEnum.class)) {
            lookupInt.put(type.getCode(), type);
            lookupString.put(type.getDesc(), type);
        }
    }


    ActivityTypeEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }


    public static ActivityTypeEnum find(Integer code) {
        return lookupInt.get(code);
    }

    public static ActivityTypeEnum find(String desc) {
        return lookupString.get(desc);
    }
}
